﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Text;
using System.Reflection;
using System.ComponentModel;

namespace Deepforest.WPF.Controls.Data
{
    public class ExpandableProperty : Property
    {
        private PropertyCollection _propertyCollection;

        public ExpandableProperty(object instance, PropertyDescriptor property)
            : base(instance, property)
        {

        }

        public ObservableCollection<Item> Items
        {
            get
            {

                if (_propertyCollection == null)
                {
                    //Lazy initialisation prevent from deep search and looping
                    _propertyCollection = new PropertyCollection(_property.GetValue(_instance), true);
                }

                return _propertyCollection.Items;
            }
        }

    }

}
